<?php
class Product extends CI_Controller{
	public function __construct(){
		parent::__construct();
		$this->load->model('model_home');
	}
	
	public function index(){
		$data['active_product'] = 'y';
		$data['title'] = TITLE.' - Product';
		$this->load->view("product",$data);
	}
	
	public function promo(){
		$data['active_promo'] = 'y';
		$data['banners'] = $this->model_home->getbanner();
		if($this->input->post("btnregister") && (!Auth::isLoggedIn()) ){
			$redirect = $this->_register();
			if($redirect) $data['register_success'] = "y";
		}
		$data['title'] = TITLE.' - Promo';
		$this->load->view("promo",$data);
	}
	
	public function detail($product_id=""){
		$data['active_product'] = 'y';	
		$data['title'] = TITLE.' - Product Detail';
		$this->load->view("product_detail",$data);
	}
	
	public function addcart(){
		if(!Auth::isLoggedIn()) redirect("/");
		if($this->session->userdata("type_user") != "user") redirect("/");
	}
	
	public function viewcart(){
		if(!Auth::isLoggedIn()) redirect("/");
		if($this->session->userdata("type_user") != "user") redirect("/");
		$data['title'] = TITLE.' - Cart';
		$this->load->view("cart",$data);
	}
	
	public function deletecart(){
		if(!Auth::isLoggedIn()) redirect("/");
	}
	

	public function checkout(){
		if(!Auth::isLoggedIn()) redirect("/");
	}
	
}